@inject IDataService DataService
@inject IAdminService AdminService
@inject IHttpContextAccessor HttpContextAccessor

<Panel Header="Security">
    @if (SecurityForm != null)
    {
        <EditForm class="flex flex-col space-y-4" FormName="@SecurityFormName" Model="SecurityForm" OnValidSubmit="@OnSecurityFormSubmittedAsync">
            <div class="flex flex-col space-y-4">
                <div class="flex flex-col space-y-2">
                    <label>
                        <InputCheckbox class="mr-1 my-4" @bind-Value="SecurityForm.IsMagicLinksEnabled"/>
                        Enable Magic Links
                    </label>
                    <Alert Style="@ContextualStyles.Info">
                        <p>Magic links allow administrators to sign into the admin console without a password.</p>
                        <ul class="list-disc list-inside">
                            <li>When enabled, if an administrator does not have their passkey, they can sign in with a magic link sent to their email.</li>
                            <li>When disabled, administrators must sign in with their passkeys. If their passkeys are lost, a different administrator must restore access.</li>
                        </ul>
                    </Alert>
                </div>
            </div>
            <div>
                <button id="update-security-btn" type="submit" class="btn-primary">Update</button>
            </div>
            <DataAnnotationsValidator/>
            <ValidationSummary/>
            <CustomValidationErrors EditContext="SecurityFormEditContext"/>
        </EditForm>
    }
</Panel>